﻿@model IEnumerable<saigonbook.Biz.BIZ_sach>
@{
    ViewBag.Title = "Kết quả tìm kiếm";
}

<div class="covercenter">
@{Html.RenderAction("KhungTimKiem","sach");}

<div class="columncenter">
    <div class="header-center">KẾT QUẢ TÌM KIẾM</div>
    
        @if (Model.Count() < 1)
        {
            <div style="width:580px">   
            <div class="noidunggiua" style="padding:10px;">
                <div class="noidungphu">@Html.Raw(ViewBag.KhongTimThay)</div>
            </div>
            </div>
        }
        else
        {
            <div style="width:580px">
            @foreach (var item in Model)
            {
                int _gia = (int)item.giaban;
                string gia = _gia.ToString("c");
                gia = gia.Substring(1, gia.LastIndexOf(".") - 1);
            <div class="sanpham">
                <a title="Chi tiết" href="/sach/chitietsanpham?masach=@Html.DisplayFor(modelItem => item.masach).ToString().Trim()"><div><img src="@Url.Content("~/" + @Html.DisplayFor(modelItem => item.hinhanh))"/></div></a>
                <div class="tensanpham" style="color:Black"><table align="center"><tr height="40px" valign="middle"><td><b>@Html.DisplayFor(modelItem => item.tensach)</b></td></tr></table></div>
                <div style="color:#FF0000"><b>Giá: @gia VNĐ</b></div>
               <table>
                        <tr>
                            <td align="right" style="width:100px;padding-left:7px; padding-right:5px">
                                <div class="muahang">
                                @{
                                    saigonbook.Biz.BIZ_tonkho tk = new saigonbook.Biz.BIZ_tonkho();
                                    tk.sach = item;
                                    tk.ngay = DateTime.Now.Date;
                                    if (tk.soluongtonkho(tk) > 0)
                                    { <a title="Thêm sản phẩm vào giỏ hàng" href="/Cart/giohangthem?masach=@Html.DisplayFor(x => item.masach)"><b>Mua hàng</b></a>}
                                    else
                                    { <b title="Hết hàng">Hết hàng</b>}
                                }
                                </div>
                            </td>
                            <td align="left" style="width:60px; padding-left:5px; padding-right:10px">
                                <div class="chitiet">
                                    <a href="/sach/chitietsanpham?masach=@Html.DisplayFor(modelItem => item.masach).ToString().Trim()">Chi tiết</a>
                                </div>
                            </td>
                        </tr>
                    </table>
            </div>
            }
        
    </div>
    <div class="clear"></div>
    <div style="width:580px; text-align:center; margin:5px 5px 7px 5px"> 
     @{Html.RenderAction("Index", "paging", new { currentpage = "sach/TimKiemNangCao?loaisach=" + @ViewBag.loaihang + "&tensach=" + @ViewBag.tensp + "&giatu=" + @ViewBag.giatu + "&den=" + @ViewBag.giaden + "&tknangcao=Tìm", totalpages = ViewBag.TotalPages });}
    </div>}
</div>
</div>

